import 'package:OASys/entity/RoleVo.dart';
import 'package:OASys/httpConfig/DioManager.dart';
import 'package:OASys/httpConfig/ErrorEntity.dart';
import 'package:OASys/httpConfig/NWMethod.dart';

class RoleApi {
  void getInfo(int id,
      {Function(RoleVo) success, Function(ErrorEntity) error}) {
    DioManager().request<RoleVo>(
      NWMethod.GET,
      "/front/role/$id",
      success: success,
      error: error,
    );
  }

  void getList(int page, int limit,
      {Function(List<RoleVo>) success, Function(ErrorEntity) error}) {
    DioManager().requestList<RoleVo>(
      NWMethod.POST,
      "/front/role/getList",
      params: {
        "page": page,
        "limit": limit,
      },
      success: success,
      error: error,
    );
  }

  void list(int page, int limit,
      {RoleVo andQuery,
      Function(List<RoleVo>) success,
      Function(ErrorEntity) error}) {
    DioManager().requestList<RoleVo>(
      NWMethod.POST,
      "/front/role/getList",
      params: {
        "page": page,
        "limit": limit,
        "andQuery": andQuery,
      },
      success: success,
      error: error,
    );
  }

  void save(RoleVo info, List<int> ids,
      {Function(String) success, Function(ErrorEntity) error}) {
    DioManager().request<String>(
      NWMethod.PUT,
      "/front/role/save",
      params: {
        "role": info,
        "menuIds": ids,
      },
      success: success,
      error: error,
    );
  }

  void remove(int id, {Function(String) success, Function(ErrorEntity) error}) {
    DioManager().request<String>(
      NWMethod.DELETE,
      "/front/role/remove/$id",
      success: success,
      error: error,
    );
  }

  void setStatus(int id, int status,
      {Function(String) success, Function(ErrorEntity) error}) {
    DioManager().request<String>(
      NWMethod.GET,
      "/front/role/setStatus/$id/$status",
      success: success,
      error: error,
    );
  }
}
